<?php

class Admin_Model_DbTable_Pointgmv extends Zend_Db_Table
{
    protected $_name = 'pointgmv';
    /**
		Recupererle point de la muraille par son id
     */
    public function getPointgmv($idpointgmv) {
        $idpointgmv = (int)$idpointgmv;
        $row = $this->fetchRow('idpointgmv = ' . $idpointgmv);
        if (!$row) {
            throw new Exception("Count not find row $idpointgmv");
        }
        return $row->toArray();    
    }
    
    public function addPointgmv($latitude, $longitude, $pointgmv_idpointgmv_pred) {
        $data = array(
            'latitude' => $latitude,
            'longitude' => $longitude,
            'pointgmv_idpointgmv_pred' => $pointgmv_idpointgmv_pred,
        );
        $this->insert($data);
    }
    
    public function addPointgmvIJ($i, $j) {
        $data = array(
            'latitude' => "",
            'longitude' => "",
            'pointgmv_idpointgmv_pred' => "",
        	'i' => $i,
       		'j' => $j,
        );
        $this->insert($data);
    }
    
    public function updatePointgmv($idpointgmv, $latitude, $longitude, $pointgmv_idpointgmv_pred) {
         $data = array(
            'latitude' => $latitude,
            'longitude' => $longitude,
            'pointgmv_idpointgmv_pred' => $pointgmv_idpointgmv_pred,
        );
        $this->update($data, 'idpointgmv = '. (int)$idpointgmv);
    }
    
    
	function deletePointgmv($idpointgmv) {
		$this->delete ( 'idpointgmv =' . ( int ) $idpointgmv );
	}
    /**
     * 
     * @return  
     */
    public function getAllPointgmv() {    
        $all = $this->fetchAll();
        $pointgmvs = array();
        $pointgmvs['total'] = count($all->toArray());
        $pointgmvs['rows'] = $all->toArray();
        return $pointgmvs ;
    }   

     public function getCoordonneee($imin,$imax,$jmin,$jmax) {    
 		$select = $this ->select()
             -> from('pointgmv')
             -> where('i > ?', $imin)
             -> where('i <= ?', $imax)
             -> where('j > ?', $jmin)
             -> where('j <= ?', $jmax);

        $result = $this -> fetchAll($select);
        $res = array();
        $i = 0;
     	foreach ($result as $row) {
     		$res[$i] = array();
 			$res[$i] = $row->toArray();
 			$res[$i]["type"] = "pointgmv";
 			$i++;

		}
        return $res;
    }
}
